function checkInputForm(form){
	var batNo = form.batNo;
	var cardNoFrom = form.cardNoFrom;
	var cardNoEnd = form.cardNoEnd;
	var design = form.design;
	var money = form.money;
	var moneyEx = form.moneyEx;
	var enddate = form.enddate;
	var inputdate = form.inputdate;
	
	var result = true;
	
	if(!checkBatNo(batNo)){
		result =  false;
	}
	
//	if(!checkCardNo(cardNoFrom,cardNoEnd)){
//		result =  false;
//	}
	
//	if(!checkDesign(design)){
//		result = false;
//	}
	
	if(!checkMoney(money)){
		result = false;
	}
	
	if(!checkMoneyEx(moneyEx)){
		result = false;
	}
	
//	if(!checkEnddate(enddate)){
//		result = false;
//	}
//	
//	if(!checkInputdate(inputdate)){
//		result = false;
//	}
	return result;
}

function checkBatNo(batNo){
	var result = false;
	
	if(batNo.value.length == 0) {
		var errorMsg = "批号不能为空！";
		document.getElementById("batNoMsg").innerHTML = getErrorMsg("batNoMsg", errorMsg);
		result = false;
	} else {
		document.getElementById("batNoMsg").innerHTML = getRightMsg();
		result = true;
	}
	
	return result;
}

function checkCardNo(cardNoFrom,cardNoEnd){
	var result = false;
	var errorMsg = "卡的起止号不合理！";
	if(cardNoFrom.value.length == 0 || cardNoEnd.value.length == 0) {
		document.getElementById("cardNoEndMsg").innerHTML = getErrorMsg("cardNoEndMsg", errorMsg);
		result = false;
	} else {
		document.getElementById("cardNoEndMsg").innerHTML = getRightMsg();
		result = true;
	}
	return result;
}

function checkDesign(design){
	return true;
}

function checkMoney(money){
	var result = false;
	var errorMsg = "请输入数字。例如：0.20";
	if(!checkRate(money)){
		document.getElementById("moneyMsg").innerHTML = getErrorMsg("moneyMsg", errorMsg);
		result = false;
	}else{
		document.getElementById("moneyMsg").innerHTML = getRightMsg();
		result = true;
	}
	return result;
}

function checkMoneyEx(moneyEx){
	var result = false;
	var errorMsg = "请输入数字。例如：0.20";
	if(!checkRate(moneyEx)){
		document.getElementById("moneyExMsg").innerHTML = getErrorMsg("moneyExMsg", errorMsg);
		result = false;
	}else{
		document.getElementById("moneyExMsg").innerHTML = getRightMsg();
		result = true;
	}
	return result;
}

function checkEnddate(enddate){
	var result = false;
	var errorMsg = "日期格式不正确！";
	if(!dateValidate(enddate)){
		document.getElementById("enddateMsg").innerHTML = getErrorMsg("enddateMsg", errorMsg);
		result = false;
	}else{
		document.getElementById("enddateMsg").innerHTML = getRightMsg();
		result = true;
	}
	return result;
}

function checkInputdate(inputdate){
	var result = false;
	var errorMsg = "日期格式不正确！";
	if(!dateValidate(inputdate)){
		document.getElementById("inputdateMsg").innerHTML = getErrorMsg("inputdateMsg", errorMsg);
		result = false;
	}else{
		document.getElementById("inputdateMsg").innerHTML = getRightMsg();
		result = true;
	}
	return result;
}

function getErrorMsg(spanId, errorMsg) {
	return "<span id='" + spanId + "' style='color:red'>" + errorMsg + "</span>";
}

function getRightMsg() {  
	return "<font size='3' color='green'><b>正确</b></font>";
}

function showMsg(msg) {
	alert(msg);
}

function checkRate(input)
{
	     var re = new RegExp("^[1-9]d*.d*|0.d*[1-9]d*$");   
	     //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
	     if (!re.test(input.value))
	    {
	        return false;
	     }
}

function dateValidate(input){
	var vals = new RegExp("^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
	if(!vals.test(str.value)){
		return false;
	}
	return true;
}
